home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Calculators / Calculette / Source / Info.m < prev    next >
Text File  |  1994-02-28  |  2KB  |  98 lines

  1. #import "Info.h"
  2.  
  3. #define POINTSIZE 18.0
  4.  
  5. static void handler( DPSTimedEntry teNumber, double now, void *userData )
  6. {
  7.   [ (id)userData animationClick ];
  8. }
  9.  
  10. @implementation InfoView
  11.  
  12. - initFrame:(const NXRect *)rect
  13. {
  14.   [ super initFrame:rect ];
  15.  
  16.   animationFont = [ Font newFont:"Symbol" size:POINTSIZE matrix:NX_IDENTITYMATRIX ];
  17.  
  18.   return self;
  19. }
  20.  
  21. - animateInfo:sender
  22. {
  23.   [ self display ];
  24.   [ self removeTE ];
  25.   
  26.   [ window setDelegate:self ];
  27.  
  28.   animationStep = 0;
  29.   animationFloat = 0;
  30.   animateTE = DPSAddTimedEntry( .001, (DPSTimedEntryProc)handler, self, NX_BASETHRESHOLD );
  31.   
  32.   return self;
  33. }
  34.  
  35. - removeTE
  36. {
  37.   if( animateTE ) {
  38.     DPSRemoveTimedEntry( animateTE );
  39.     animateTE = 0;
  40.   }
  41.  
  42.   return self;
  43. }
  44.  
  45. - windowWillClose:sender
  46. {
  47.   [ self removeTE ];
  48.   [ window setDelegate:nil ];
  49.   
  50.   return self;
  51. }
  52.  
  53. - animationClick
  54. {
  55.   char *dropstrings[ 4 ] = { "+", "-", "\264", "\270" };
  56.   const float step = 2.0;
  57.  
  58.   float x = NX_WIDTH( &frame ) - animationFloat;
  59.   float y = 0;
  60.  
  61.   [ self lockFocus ];
  62.  
  63.   [ animationFont set ];
  64.  
  65.   PSsetgray( NX_LTGRAY );
  66.   PSmoveto( x, y );
  67.   PSshow( dropstrings[ animationStep ] );
  68.  
  69.   PSsetgray( NX_BLACK );
  70.   PSmoveto( x - step, y );
  71.   PSshow( dropstrings[ animationStep ] );
  72.  
  73.   PSflushgraphics( );
  74.  
  75.   [ self unlockFocus ];
  76.  
  77.   animationFloat += step;
  78.  
  79.   if ( animationFloat >= NX_WIDTH( &bounds ) - animationStep * 10 ) {
  80.     animationFloat = 0;
  81.     animationStep++;
  82.     if( animationStep == 4 )
  83.       [ self removeTE ];
  84.   }
  85.  
  86.   return self;
  87. }
  88.  
  89. - drawSelf:(const NXRect *)rects:(int)rectCount
  90. {
  91.   PSsetgray( NX_LTGRAY );
  92.   NXRectFill( &bounds );
  93.   
  94.   return self;
  95. }
  96.  
  97. @end
  98.